package fem2d;

import fem2.AbstractStructuralStaticDemo;
import fem2.MaterialModel;
import fem2.Model;
import fem2.Observer;
import fem2.enu.State;
import fem2.material.FluencyCriteria;
import fem2.material.LinearIsotropicHardeningRule;
import fem2.material.LinearKinematicHardeningRule;
import fem2.material.VonMisesMM;
import fem2.observer.GidPlasticityObserver;
import fem2.observer.TimeStepObserver;
import fem2.strategies.Strategy;

public class NotchBeamVonMises extends NotchBeamIsotropicDamage {

	public NotchBeamVonMises() {
		projectDir = "/home/hbui/kratos_janosch";
		projectName = "notchbeam.gid";
		meshFileName = "mesh1-vonmises.msh";
	}

	@Override
	public MaterialModel createMaterial(Model m) {
		double E = 2;
		double nu = 0.3;
		double t = 1.0;
		double ft = 0.91;
		double K = 1.0;
		double H = 1.0;

		FluencyCriteria isoLaw = new LinearIsotropicHardeningRule(ft, K);
		FluencyCriteria kinLaw = new LinearKinematicHardeningRule(H);
		return new VonMisesMM(E, nu, t, 0.0, State.PLANE_STRAIN, isoLaw, kinLaw);
	}

	@Override
	public void addObservers(Model m, Strategy s, TimeStepObserver o) {
		addFundamentalObservers(m, s, o);

		if (meshFileName == null) {
			throw new Error("mesh file name was not set");
		}

		/*
		 * clean all previous post files
		 */
		String meshName = meshFileName.split("\\.")[0];

		Observer po = new GidPlasticityObserver(m, o, projectDir, projectName, meshName);
		s.addObserver(po);

	}

	public static void main(String[] args) {
		AbstractStructuralStaticDemo demo = new NotchBeamVonMises();

		demo.run(20);
		// demo.run(600);
	}
}
